import request from '@/utils/request'

// 查询订单信息列表
export function listOrderDetailInfo(query) {
  return request({
    url: '/buyers/orderDetailInfo/list',
    method: 'get',
    params: query
  })
}

// 查询所有商品销售量
export function goodSalesVolume() {
  return request({
    url: '/system/chart/goodSalesVolume',
    method: 'get',
  })
}

// 查询所有商品销售金额
export function goodSales() {
  return request({
    url: '/system/chart/goodSales',
    method: 'get',
  })
}

// 查询订单信息详细
export function listOrderDetailInfoVO(orderId) {
  return request({
    url: '/buyers/orderDetailInfo/listVO/' + orderId,
    method: 'get'
  })
}

// 查询订单信息详细
export function getOrderDetailInfo(orderId) {
  return request({
    url: '/buyers/orderDetailInfo/' + orderId,
    method: 'get'
  })
}

// 新增订单信息
export function addOrderDetailInfo(data,details) {
  request({
    url: '/buyers/orderDetailInfo',
    method: 'post',
    data: data
  }).then(async order => {
    console.log(details)
    await request({
      url: '/buyers/orderDetailInfo/addInfo/'+order.msg,
      method: 'post',
      data: details
    })
  });
}

// 修改订单信息
export function updateOrderDetailInfo(data) {
  return request({
    url: '/buyers/orderDetailInfo',
    method: 'put',
    data: data
  })
}

// 删除订单信息
export function delOrderDetailInfo(orderId) {
  return request({
    url: '/buyers/orderDetailInfo/' + orderId,
    method: 'delete'
  })
}
